package com.yzd.crm.service.impl;

import com.yzd.crm.dao.CustomerDao;
import com.yzd.crm.domain.BaseDict;
import com.yzd.crm.domain.Customer;
import com.yzd.crm.service.CustomerService;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: Ye Zhengdong
 * @Date: 2019/4/3 14:09
 * @Description:
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerDao customerDao;
    @Override
    @Transactional(readOnly=false, propagation= Propagation.REQUIRED)
    public void add(Customer customer) {
        customerDao.addCustomer(customer);
    }

    @Override
    public List<BaseDict> findLevel(String code) {
        return customerDao.findLevel(code);
    }

    @Override
    public List<BaseDict> findSource(String code) {
        return customerDao.findSource(code);
    }

    @Override
    public List<BaseDict> findIndustry(String code) {
        return customerDao.findIndustry(code);
    }

    @Override
    @Transactional(readOnly=false, propagation= Propagation.REQUIRED)
    public void save(Customer customer) {
        customerDao.save(customer);
    }

    @Override
    public List<Customer> findAll() {
        return customerDao.findAll();
    }

    @Override
    public List<Customer> conditionFind(DetachedCriteria dc) {
        return customerDao.conditionFind(dc);
    }

    @Override
    public Customer findById(Integer id) {
        return customerDao.findById(id);
    }

    @Override
    @Transactional(readOnly=false, propagation= Propagation.REQUIRED)
    public void update(Customer customer) {
        customerDao.update(customer);
    }

    @Override
    @Transactional(readOnly=false, propagation= Propagation.REQUIRED)
    public void delete(Customer customer) {
        customerDao.delete(customer);
    }
}
